import pymysql


class MysqlHelper(object):
    # 需要有 MySQL 的链接
    # 还需要有 cursor 游标
    def __init__(self):
        self.conn = pymysql.connect(host='localhost', port=3306, user='root', password='qaz3357375', db='spiders', charset='utf8mb4')

        self.cursor = self.conn.cursor()

    def execute_modify_sql(self, sql, data):
        self.cursor.execute(sql, data)
        self.conn.commit()

    def __del__(self):
        self.cursor.close()
        self.conn.close()


